$("#tj").on("click", function () {
    event.preventDefault();
    var Uname = $("#Uname").val();
    var Upassword = $("#Upassword").val();
    var Utype = $("#Utype").val();
    $.ajax("login.do", {
        type: "post",
        data: {
            Uname: Uname,
            Upassword: Upassword,
            Utype: Utype
        },
        dataType: "json",
        success: function (d) {
            if (d == "success") {
                localStorage.setItem("name", Uname);
                window.location.href = "index.html";
            }
            if (d == "error") {
                $("#jg").text("登录失败，密码不正确").css("color", "red");
            }
            if (d == "error2") {
                $("#jg").text("登录失败，账号不存在").css("color", "red");
            }
            if (d == "success" && Utype == "管理员") {
                localStorage.setItem("AdminName", Uname);
                window.location.href = "AdminIndex.html";
            }
        }
    });
});